package com.vcg.filters;

import org.springframework.cloud.gateway.filter.GlobalFilter;
import org.springframework.cloud.gateway.filter.factory.GatewayFilterFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.Ordered;
import org.springframework.core.annotation.Order;

@Configuration
public class FilterConfig {

    // 以下是全局的过滤器(注意这里我们保持它为最高优先级)
    @Bean
    @Order(value = Ordered.HIGHEST_PRECEDENCE)
    public GlobalFilter costFilter(){
        return new CostFilter();
    }
    // 以下是自定义的的过滤器工厂
    @Bean
    public GatewayFilterFactory exampleGatewayFilterFactory(){
        return new ExampleGatewayFilterFactory(1);
    }
}
